<?php
/**
 * @author Admin
 *
 */
class ConfigureGalleryView extends GalleryView {

	/**
	 *
	 * @see GalleryView::render()
	 */
	public  function render( $config = NULL ) {
		    $cur = $this->_controller->uri->segment(6, 0);
			$renderer = new MultipleImageGallery();
			$renderer->base = 'templates/multiple_configure_gallery';
			$ci = & get_instance();
			$renderer->content_editor_type = $ci->input->post('content_editor_type');
			if(!empty($config["selectedIds"])){
				$test = $config["selectedIds"];
			}
			foreach ( $this->query as $dat ){	
				$selected = TRUE;	
				if(  !empty($test) ){
					if(strpos($test,$dat->id) !== false){
						$selected = TRUE;
					}
					else {
						$selected = FALSE;
					}
				}
				else {
					$selected = TRUE;
				}
				if($config["thumb"]){
					$img =new Image($dat->location, (int)$config["maxwidth"],$dat->width,$dat->height,"/thumbs_",TRUE);
				}
				else {
					$img =new Image($dat->location, (int)$config["maxwidth"],$dat->width,$dat->height);
				}
				$img->finalize();
				$wrapper = new ImageSelectorWrapper($dat->title);
				$wrapper->id = "img$dat->id";
				$wrapper->imgId = $dat->id;
				$wrapper->selected = $selected;				
				$wrapper->title = $dat->title;
				$wrapper->preview = $dat->location;
				$wrapper->addChild($img);
				$wrapper->finalize();
				$renderer->addChild($wrapper);
//				$renderer->addJSInit("$(function() {
//			$('div.imgsection img').verticalAlign();
//			});"); 
			}
			$renderer->finalize();
//			$this->display->addJSInit("
//				$(function() {
//					$('.imgsection a').delay(100).queue( function(){ 
//						$('.imgsection a').verticalAlign();
//					});
//				});
//			");
			$this->display->addChild($renderer,'gallery_item_template');
	}
}


?>